<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>nonrandom</title>
</head>

<body>
    <div>打开浏览器控制台查看结果</div>
    <script>
        function nonrandom(...num) {
            if (Array.isArray(num[0])) {
                num = num[0];
            }
            let maxNum = parseInt(num[0]) || 10,
                minNum = parseInt(num[1]) || 1;
            if (minNum === maxNum) {
                return maxNum;
            }
            minNum > maxNum ? ([minNum, maxNum] = [maxNum, minNum]) : '';
            let randomArr = [];
            for (let i = minNum; i <= maxNum; i++) {
                randomArr.push(i);
            }
            let index = randomArr.length;
            while (index) {
                const r = Math.floor(Math.random() * index--);
                [randomArr[r], randomArr[index]] = [randomArr[index], randomArr[r]];
            }
            return randomArr;
        }
        console.log(nonrandom());
    </script>
</body>

</html>